#include "ParamResearchView.h"
#include "ui_ParamResearchForm.h"
#include "SettingHelper.h"


ParamResearchView::ParamResearchView(QWidget *parent) : QWidget(parent),
  ui(new Ui::ParamResearch)
{
    ui->setupUi(this);


    SettingHelper *settingHelper = SettingHelper::getSettingHelper();

    ui->checkBox1->setChecked(settingHelper->m_ParamResearch.paramEnable);
    ui->checkBox2->setChecked(settingHelper->m_ParamResearch.printEnbale);
    ui->checkBox3->setChecked(settingHelper->m_ParamResearch.declarEnable);
    ui->ch_textEditRemark->setText(settingHelper->m_ParamResearch.declarString);


    ui->checkBox2->setEnabled(ui->checkBox1->isChecked());
    ui->checkBox3->setEnabled(ui->checkBox1->isChecked());

}

ParamResearchView::~ParamResearchView()
{
    delete ui;
}

void ParamResearchView::closeEvent(QCloseEvent *)
{
  saveSettings();
}

void ParamResearchView::saveSettings()
{
   SettingHelper *settingHelper = SettingHelper::getSettingHelper();

   settingHelper->m_ParamResearch.paramEnable = ui->checkBox1->isChecked();
   settingHelper->m_ParamResearch.printEnbale = ui->checkBox2->isChecked();
   settingHelper->m_ParamResearch.declarEnable = ui->checkBox3->isChecked();
   settingHelper->m_ParamResearch.declarString = ui->ch_textEditRemark->toPlainText();
}


void ParamResearchView::on_checkBox1_clicked(bool checked)
{
    ui->checkBox2->setEnabled(checked);
    ui->checkBox3->setEnabled(checked);
}
